# -*- coding: utf-8 -*-
from mxit.handles import *

class UserContact:
    def __init__(self, user, alias=None, group=''):
        if alias == None:
            alias = user.name
            
        self.user = user
        self.alias = alias
        self.group = group
        
    
class User:
    def __init__(self, jid, name=None, birthdate=u'1900-01-01', gender=Gender.MALE, private=PrivateNumber.NO, presence=Presence.OFFLINE, type=BuddyType.MXIT, mood=Mood.NONE):
        self.jid = jid
        self.name = name
        self.birthdate = birthdate
        self.gender = gender
        self.private = private
        self.type = type
        
        self.presence = presence
        self.mood = mood
        
        self.contacts = []
        
        
        self.con = None
        
    def add_contact(self, contact):
        self.contacts.append(contact)
        
    def get_contact(self, user):
        for contact in self.contacts:
            if contact.user == user:
                return contact
        return None
    
    
class UserList(dict):
    def __init__(self):
        dict.__init__(self)
        
        self.info = User(u'info@services.mxit.co.za', u'Info', type=BuddyType.INFO, presence=Presence.AVAILABLE)
        self.banker = User(u'joebanker@tradepost.svc.mxit.co.za', u'JoeBanker', type=BuddyType.SERVICE, presence=Presence.BUSY, mood=Mood.GRUMPY)
        self.echo = User(u'mirror@mxit.co.za', u'Mirror', type=BuddyType.SERVICE, presence=Presence.AVAILABLE)
        self.chatter = User(u'chatter@mxit.co.za', u'Chatter', type=BuddyType.MXIT, presence=Presence.AVAILABLE)
        self.chatter2 = User(u'chatter2@mxit.co.za', u'Chatter2', type=BuddyType.MXIT, presence=Presence.AWAY)
        
        self.add(self.info)
        self.add(self.banker)
        self.add(self.echo)
        self.add(self.chatter)
        self.add(self.chatter2)
        
    def add(self, user):
        self[user.jid] = user